from rest_framework import serializers
from .models import City, DataCenter, Host, HostCredential, HostStatistic


class CitySerializer(serializers.ModelSerializer):
    class Meta:
        model = City
        fields = '__all__'


class DataCenterSerializer(serializers.ModelSerializer):
    city = CitySerializer()

    class Meta:
        model = DataCenter
        fields = '__all__'


class HostSerializer(serializers.ModelSerializer):
    data_center = DataCenterSerializer()

    class Meta:
        model = Host
        fields = '__all__'


class HostCredentialSerializer(serializers.ModelSerializer):
    class Meta:
        model = HostCredential
        fields = ['root_password', 'last_updated']
        extra_kwargs = {
            'root_password': {'write_only': True}
        }


class HostStatisticSerializer(serializers.ModelSerializer):
    class Meta:
        model = HostStatistic
        fields = '__all__'